home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Archive-tools / LZSS Res ƒ / utils.c < prev    next >
Text File  |  1993-06-06  |  2KB  |  84 lines

  1. /*
  2.     Copyright © 1994 Demos, inc.
  3.     Written by: Dmitry Boldyrev
  4. */
  5.  
  6. #include "utils.h"
  7.  
  8. RgnHandle gOldVisRgn = NULL;
  9.  
  10. void CenterRect(Rect srcRect, Rect* dstRect)
  11. {
  12.     short width = (dstRect->right - dstRect->left);
  13.     short height = (dstRect->bottom - dstRect->top);
  14.  
  15.     dstRect->left = srcRect.left + (((srcRect.right - srcRect.left) / 2) - (width / 2));
  16.     dstRect->top = srcRect.top + (((srcRect.bottom - srcRect.top) / 2) - (height / 2));
  17.     dstRect->right = dstRect->left + width;
  18.     dstRect->bottom = dstRect->top + height;
  19. }
  20.  
  21.  
  22. void HideMenuBar(GrafPtr grafPort)
  23. {
  24.     RgnHandle newVisRgn;
  25.     GrafPtr savePort;
  26.  
  27.     GetPort(&savePort);
  28.     SetPort(grafPort);
  29.  
  30.         // save off vis region
  31.     gOldVisRgn = NewRgn();
  32.     CopyRgn(grafPort->visRgn, gOldVisRgn);
  33.  
  34.         // expand the vis region to the port rect
  35.     newVisRgn = NewRgn();
  36.     RectRgn(newVisRgn, &grafPort->portRect);
  37.     CopyRgn(newVisRgn, grafPort->visRgn);
  38.     DisposeRgn(newVisRgn);
  39.  
  40.     SetPort(savePort);
  41. }
  42.  
  43. void ShowMenuBar(GrafPtr grafPort)
  44. {
  45.     GrafPtr savePort;
  46.     RgnHandle junkRgn;
  47.  
  48.     GetPort(&savePort);
  49.     SetPort(grafPort);
  50.  
  51.         // fill the rounded corners of the screen with black again
  52.     junkRgn = NewRgn();
  53.     CopyRgn(gOldVisRgn, junkRgn);
  54.     DiffRgn(grafPort->visRgn, junkRgn, junkRgn);
  55.  
  56.     #ifdef dangerousPattern
  57.     FillRgn(junkRgn, qd.black);
  58.     #else
  59.     FillRgn(junkRgn, &qd.black);
  60.     #endif
  61.  
  62.     DisposeRgn(junkRgn);
  63.  
  64.         // restore the old vis region
  65.     CopyRgn(gOldVisRgn, grafPort->visRgn);
  66.     DisposeRgn(gOldVisRgn);
  67.     gOldVisRgn = NULL;
  68.  
  69.     DrawMenuBar();
  70. }
  71.  
  72. CGrafPtr CreateWindow(Rect *tempR, Str255 title, short win_type, long app_handle)
  73. {
  74.     short                    mbarheight = GetMBarHeight();
  75.     CGrafPtr                wintemp;
  76.  
  77. //    if ( ( tempR->top < mbarheight ) && !gMenuBarHidden )
  78. //        HideMenuBar();
  79.     
  80.     wintemp = (CWindowPtr)NewCWindow( nil, tempR, title, true, win_type, (WindowPtr)-1, false, app_handle );
  81.     return( wintemp );
  82.  
  83. }
  84.